
---

## 📄 `CMakeLists.txt`

```cmake
# CMakeLists.txt - 小说创作智能体系统
cmake_minimum_required(VERSION 3.14)
project(NovelCreationAgent LANGUAGES CXX)

# 设置 C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# 编译选项
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O2")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O2")
endif()

# 包含目录
include_directories(include)
include_directories(src)

# 主程序
add_executable(novel_assistant
    src/main.cpp
    src/project_manager.cpp
    agents/world_builder_agent.cpp
    agents/character_agent.cpp
    agents/plot_agent.cpp
)

# 插件：角色生成器（上下文感知）
add_library(char_gen_context SHARED
    plugins/character_generator_context_aware.cpp
)
target_include_directories(char_gen_context PRIVATE include)
set_target_properties(char_gen_context PROPERTIES PREFIX "lib")

# 链接（如果有外部库，如 nlohmann/json 已嵌入，无需链接）
# target_link_libraries(novel_assistant some_lib)

# 构建后自动创建测试项目
add_custom_command(TARGET novel_assistant POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/my_epic_novel
    COMMENT "Creating test project directory..."
)

# 安装规则（可选）
install(TARGETS novel_assistant DESTINATION bin)
install(DIRECTORY agents/ DESTINATION agents)
install(DIRECTORY plugins/ DESTINATION plugins)

# 输出信息
message(STATUS "✅ 构建完成！运行: ./novel_assistant")